/* 
 * FILE: readwriter.c
 */
/* dos.c*/

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>

int main (void){

	int fd,i;
	int count = 0;
	char b[40] = "Testing scheduler";

	if ((fd=open("schedTest.dat", O_RDWR | O_CREAT | O_TRUNC, 0644)) ==-1){
		printf("Open error\n");
		return -1;
	}
	while ( count < 10000)
	{
		if (write (fd, b, 40) == -1){
			printf("Write error\n");
			return -1;
		}
		for( i=0 ;  i<40 ; i++)
			b[i] = 'p';
		lseek(fd, 0L, SEEK_SET);
		if (read(fd, b, 40) == -1)
		{
			printf("Read error\n");
			return -1;
		}
		printf("Read: %s\n", b);
		count++;
	}
}
